/**************************************************************************
 *                                                                        *
 *  Algorithmic C (tm) Math Library                                       *
 *                                                                        *
 *  Software Version: 3.4                                                 *
 *                                                                        *
 *  Release Date    : Thu Nov 17 21:43:31 PST 2022                        *
 *  Release Type    : Production Release                                  *
 *  Release Build   : 3.4.5                                               *
 *                                                                        *
 *  Copyright 2018 Siemens                                                *
 *                                                                        *
 **************************************************************************
 *  Licensed under the Apache License, Version 2.0 (the "License");       *
 *  you may not use this file except in compliance with the License.      * 
 *  You may obtain a copy of the License at                               *
 *                                                                        *
 *      http://www.apache.org/licenses/LICENSE-2.0                        *
 *                                                                        *
 *  Unless required by applicable law or agreed to in writing, software   * 
 *  distributed under the License is distributed on an "AS IS" BASIS,     * 
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or       *
 *  implied.                                                              * 
 *  See the License for the specific language governing permissions and   * 
 *  limitations under the License.                                        *
 **************************************************************************
 *                                                                        *
 *  The most recent version of this package is available at github.       *
 *                                                                        *
 *************************************************************************/
//*************************************************************************
// File: ac_sincos_lut.h
//
// Description:
//    Provides lookup based implementation of the sine and cosine functions
//    for the AC Datatype ac_fixed.
//
// Usage:
//    A sample testbench and its implementation look like
//    this:
//    #include <ac_fixed.h>
//    #include <ac_complex.h>
//    #include <ac_math/ac_sincos_lut.h>
//    #include <mc_scverify.h>
//    using namespace ac_math;
//
//    typedef ac_fixed<11, 4, true, AC_RND, AC_SAT> input_type;
//    typedef ac_complex<ac_fixed<23, 1, true, AC_RND, AC_SAT> > T_out;
//
//    #pragma hls_design top
//    void CCS_BLOCK(project)(
//      const input_type &input,
//      T_out &output,
//    )
//    {
//      ac_sincos_lut(input, sinoutput, cosoutput);
//    }
//    #ifndef __SYNTHESIS__
//    CCS_MAIN(int argc, char *argv[])
//    {
//      input_type input = 0.26;
//      T_out output;
//      CCS_DESIGN(project) (input, output);
//      CCS_RETURN (0);
//    }
//    #endif
//
// Notes:
//    In this file, the input is scaled in the range of 0-1 radians/2PI. Then
//    with the help of trigonometric identities and the lookup table the sin
//    and cos values of the input are found out.
// Example:
//    If the input is 0.26, the octant variable (which represents the first
//    3 bits of the scaled input from the MSB side) determines the octant in
//    which 0.26 lies. In this case it would be the third octant. The
//    (MSB-3 : LSB) of the scaled input helps in determining the index to the
//    lookup table.
//
// Revision History:
//    2.0.10 - Official open-source release as part of the ac_math library.
//
//***************************************************************************

#ifndef _INCLUDED_AC_SINCOS_LUT_H_
#define _INCLUDED_AC_SINCOS_LUT_H_

// Include headers for data types supported by these implementations
#include <ac_fixed.h>
#include <ac_complex.h>

#if !defined(__SYNTHESIS__)
#include <iostream>
#endif

//============================================================================
// Function: ac_sincos_lut (for ac_fixed)
//
// Description:
//    Looking up the sine and cosine lookup tables for finding the sine and
//    cosine values of real inputs, passed as ac_fixed variables.
//
// Usage:
//    See above example code for usage.
//
// Notes:
//    The lookup table based implementation utilizes lookup tables for sine
//    and cosine values. The implementation will not be bit accurate
//    compared with the math.h (double) function. The difference will be
//    confined to the quantization error of the requested output.
//-------------------------------------------------------------------------

namespace ac_math
{
  template<class T_in, class T_out>
  void ac_sincos_lut(
    const T_in &input,
    ac_complex<T_out> &output
  )
  {
    static bool flag = true;
    if (flag && T_in::width-T_in::i_width > 12) {
      #ifndef __SYNTHESIS__
      std::cout << "FILE : " << __FILE__ << ", LINE : " << __LINE__ << std::endl;
      std::cout << "Warning: The output will not be accurate" << std::endl;
      #endif
      flag = false;
    }
    typedef ac_complex<T_out> outputcomplex_type;
    // Datatype for lookup table entries
    typedef ac_complex<ac_fixed <T_out::width, T_out::i_width, false, AC_RND> > luttype;
    // Datatype for posinput which is used to handle negative inputs
    typedef ac_fixed<T_in::width-T_in::i_width, 0, false> posinputtype;

    typedef ac_int<9, false> lutindextype; // 9 bits required for indexing into 512 entry table
    typedef ac_int<3, false> octanttype;   // 3 bits required for octant value range of 0 thru 7
    outputcomplex_type outputtemp;
    lutindextype lut_index = 0;
    posinputtype posinput = input;

    // Start of code generated by ac_sincos_lut_lutgen.cpp
    static const luttype sincos[512]= {
      {1.0000000000000000000000, 0.0000000000000000000000}, //index = 0, scaled angle = 0
      {0.9999988234517018792502, 0.0015339801862847655001}, //index = 1, scaled angle = 0.000244140625
      {0.9999952938095761911796, 0.0030679567629659761432}, //index = 2, scaled angle = 0.00048828125
      {0.9999894110819284032132, 0.0046019261204485704952}, //index = 3, scaled angle = 0.000732421875
      {0.9999811752826011090889, 0.0061358846491544752691}, //index = 4, scaled angle = 0.0009765625
      {0.9999705864309741398799, 0.0076698287395310970130}, //index = 5, scaled angle = 0.001220703125
      {0.9999576445519638978610, 0.0092037547820598194365}, //index = 6, scaled angle = 0.00146484375
      {0.9999423496760239116199, 0.0107376591672644905451}, //index = 7, scaled angle = 0.001708984375
      {0.9999247018391445029906, 0.0122715382857199253874}, //index = 8, scaled angle = 0.001953125
      {0.9999047010828528980753, 0.0138053885280603905877}, //index = 9, scaled angle = 0.002197265625
      {0.9998823474542125611109, 0.0153392062849881001541}, //index = 10, scaled angle = 0.00244140625
      {0.9998576410058238606027, 0.0168729879472817104191}, //index = 11, scaled angle = 0.002685546875
      {0.9998305817958234031906, 0.0184067299058048201854}, //index = 12, scaled angle = 0.0029296875
      {0.9998011698878842556937, 0.0199404285515144413798}, //index = 13, scaled angle = 0.003173828125
      {0.9997694053512152789764, 0.0214740802754695113419}, //index = 14, scaled angle = 0.00341796875
      {0.9997352882605616830602, 0.0230076814688393756214}, //index = 15, scaled angle = 0.003662109375
      {0.9996988186962042499673, 0.0245412285229122950625}, //index = 16, scaled angle = 0.00390625
      {0.9996599967439592226981, 0.0260747178291039077846}, //index = 17, scaled angle = 0.004150390625
      {0.9996188224951786382988, 0.0276081457789657501445}, //index = 18, scaled angle = 0.00439453125
      {0.9995752960467492176377, 0.0291415087641937360641}, //index = 19, scaled angle = 0.004638671875
      {0.9995294175010931425618, 0.0306748031766366398287}, //index = 20, scaled angle = 0.0048828125
      {0.9994811869661669456733, 0.0322080254083045997016}, //index = 21, scaled angle = 0.005126953125
      {0.9994306045554617323745, 0.0337411718513776007211}, //index = 22, scaled angle = 0.00537109375
      {0.9993776703880028478011, 0.0352742388982139679077}, //index = 23, scaled angle = 0.005615234375
      {0.9993223845883495437548, 0.0368072229413588525304}, //index = 24, scaled angle = 0.005859375
      {0.9992647472865944235920, 0.0383401203735527149052}, //index = 25, scaled angle = 0.006103515625
      {0.9992047586183638863133, 0.0398729275877398314787}, //index = 26, scaled angle = 0.00634765625
      {0.9991424187248169053177, 0.0414056409770767672174}, //index = 27, scaled angle = 0.006591796875
      {0.9990777277526453614698, 0.0429382569349408479975}, //index = 28, scaled angle = 0.0068359375
      {0.9990106858540733769658, 0.0444707718549386954443}, //index = 29, scaled angle = 0.007080078125
      {0.9989412931868568712446, 0.0460031821309146576882}, //index = 30, scaled angle = 0.00732421875
      {0.9988695499142835609874, 0.0475354841569593372652}, //index = 31, scaled angle = 0.007568359375
      {0.9987954562051724050065, 0.0490676743274180496290}, //index = 32, scaled angle = 0.0078125
      {0.9987190122338729381113, 0.0505997490368993163568}, //index = 33, scaled angle = 0.008056640625
      {0.9986402181802652711085, 0.0521317046802833583552}, //index = 34, scaled angle = 0.00830078125
      {0.9985590742297593136456, 0.0536635376527305613115}, //index = 35, scaled angle = 0.008544921875
      {0.9984755805732947742115, 0.0551952443496899758379}, //index = 36, scaled angle = 0.0087890625
      {0.9983897374073401609351, 0.0567268211669077898618}, //index = 37, scaled angle = 0.009033203125
      {0.9983015449338928926082, 0.0582582645004358010143}, //index = 38, scaled angle = 0.00927734375
      {0.9982110033604781884620, 0.0597895707466399167762}, //index = 39, scaled angle = 0.009521484375
      {0.9981181129001491791897, 0.0613207363022086268667}, //index = 40, scaled angle = 0.009765625
      {0.9980228737714862408126, 0.0628517575641614617554}, //index = 41, scaled angle = 0.010009765625
      {0.9979252861985959954794, 0.0643826309298575066853}, //index = 42, scaled angle = 0.01025390625
      {0.9978253504111116445330, 0.0659133527970038463062}, //index = 43, scaled angle = 0.010498046875
      {0.9977230666441916362430, 0.0674439195636640925757}, //index = 44, scaled angle = 0.0107421875
      {0.9976184351385195547834, 0.0689743276282667738819}, //index = 45, scaled angle = 0.010986328125
      {0.9975114561403034540987, 0.0705045733896138837604}, //index = 46, scaled angle = 0.01123046875
      {0.9974021299012753027924, 0.0720346532468893463452}, //index = 47, scaled angle = 0.011474609375
      {0.9972904566786902069708, 0.0735645635996674401857}, //index = 48, scaled angle = 0.01171875
      {0.9971764367353261881988, 0.0750943008479213192086}, //index = 49, scaled angle = 0.011962890625
      {0.9970600703394829622539, 0.0766238613920314920458}, //index = 50, scaled angle = 0.01220703125
      {0.9969413577649821611715, 0.0781532416327942319745}, //index = 51, scaled angle = 0.012451171875
      {0.9968202992911656679098, 0.0796824379714301117561}, //index = 52, scaled angle = 0.0126953125
      {0.9966968952028960604395, 0.0812114468095924274538}, //index = 53, scaled angle = 0.012939453125
      {0.9965711457905548353864, 0.0827402645493756777606}, //index = 54, scaled angle = 0.01318359375
      {0.9964430513500426300766, 0.0842688875933240433280}, //index = 55, scaled angle = 0.013427734375
      {0.9963126121827780012907, 0.0857973123444398660942}, //index = 56, scaled angle = 0.013671875
      {0.9961798285956969811750, 0.0873255352061920314677}, //index = 57, scaled angle = 0.013916015625
      {0.9960447009012519670179, 0.0888535525825245586784}, //index = 58, scaled angle = 0.01416015625
      {0.9959072294174117212506, 0.0903813608778649413278}, //index = 59, scaled angle = 0.014404296875
      {0.9957674144676598171344, 0.0919089564971326822285}, //index = 60, scaled angle = 0.0146484375
      {0.9956252563809943056938, 0.0934363358457477310992}, //index = 61, scaled angle = 0.014892578125
      {0.9954807554919269385607, 0.0949634953296389361377}, //index = 62, scaled angle = 0.01513671875
      {0.9953339121404822797956, 0.0964904313552525233488}, //index = 63, scaled angle = 0.015380859375
      {0.9951847266721969287318, 0.0980171403295605342398}, //index = 64, scaled angle = 0.015625
      {0.9950331994381186317966, 0.0995436186600692496373}, //index = 65, scaled angle = 0.015869140625
      {0.9948793307948056163781, 0.1010698627548277384047}, //index = 66, scaled angle = 0.01611328125
      {0.9947231211043257026461, 0.1025958690224361979926}, //index = 67, scaled angle = 0.016357421875
      {0.9945645707342554153740, 0.1041216338720544892782}, //index = 68, scaled angle = 0.0166015625
      {0.9944036800576790957606, 0.1056471537134105187494}, //index = 69, scaled angle = 0.016845703125
      {0.9942404494531879022290, 0.1071724249568087455886}, //index = 70, scaled angle = 0.01708984375
      {0.9940748793048794773597, 0.1086974440131386054897}, //index = 71, scaled angle = 0.017333984375
      {0.9939069700023560605118, 0.1102222072938829483535}, //index = 72, scaled angle = 0.017578125
      {0.9937367219407245988450, 0.1117467112111264759822}, //index = 73, scaled angle = 0.017822265625
      {0.9935641355205953040297, 0.1132709521775642214081}, //index = 74, scaled angle = 0.01806640625
      {0.9933892111480806530466, 0.1147949266065099588330}, //index = 75, scaled angle = 0.018310546875
      {0.9932119492347945000077, 0.1163186309119046274452}, //index = 76, scaled angle = 0.0185546875
      {0.9930323501978514100230, 0.1178420615083248385035}, //index = 77, scaled angle = 0.018798828125
      {0.9928504144598651048881, 0.1193652148109912158880}, //index = 78, scaled angle = 0.01904296875
      {0.9926661424489480189948, 0.1208880872357769309389}, //index = 79, scaled angle = 0.019287109375
      {0.9924795345987099670637, 0.1224106751992160430076}, //index = 80, scaled angle = 0.01953125
      {0.9922905913482573669882, 0.1239329751185120065404}, //index = 81, scaled angle = 0.019775390625
      {0.9920993131421917965440, 0.1254549834115460948958}, //index = 82, scaled angle = 0.02001953125
      {0.9919057004306093272561, 0.1269766964968856992613}, //index = 83, scaled angle = 0.020263671875
      {0.9917097536690995251973, 0.1284981107937930022711}, //index = 84, scaled angle = 0.0205078125
      {0.9915114733187440076989, 0.1300192227222331797787}, //index = 85, scaled angle = 0.020751953125
      {0.9913108598461154441495, 0.1315400287028829495739}, //index = 86, scaled angle = 0.02099609375
      {0.9911079137232768898613, 0.1330605251571388980558}, //index = 87, scaled angle = 0.021240234375
      {0.9909026354277800097137, 0.1345807085071260011944}, //index = 88, scaled angle = 0.021484375
      {0.9906950254426646340633, 0.1361005751757060067142}, //index = 89, scaled angle = 0.021728515625
      {0.9904850842564570934101, 0.1376201215864858440341}, //index = 90, scaled angle = 0.02197265625
      {0.9902728123631691081741, 0.1391393441638260064508}, //index = 91, scaled angle = 0.022216796875
      {0.9900582102622971225614, 0.1406582393328490165896}, //index = 92, scaled angle = 0.0224609375
      {0.9898412784588205282077, 0.1421768035194478363437}, //index = 93, scaled angle = 0.022705078125
      {0.9896220174632008870219, 0.1436950331502942490580}, //index = 94, scaled angle = 0.02294921875
      {0.9894004277913803768740, 0.1452129246528472417133}, //index = 95, scaled angle = 0.023193359375
      {0.9891765099647810144390, 0.1467304744553615258873}, //index = 96, scaled angle = 0.0234375
      {0.9889502645103029898621, 0.1482476789868958089169}, //index = 97, scaled angle = 0.023681640625
      {0.9887216919603237785807, 0.1497645346773212871039}, //index = 98, scaled angle = 0.02392578125
      {0.9884907928526966980343, 0.1512810379573299723877}, //index = 99, scaled angle = 0.024169921875
      {0.9882575677307495753965, 0.1527971852584431855515}, //index = 100, scaled angle = 0.0244140625
      {0.9880220171432836373526, 0.1543129730130198551397}, //index = 101, scaled angle = 0.024658203125
      {0.9877841416445721778317, 0.1558283976542649829078}, //index = 102, scaled angle = 0.02490234375
      {0.9875439417943593367610, 0.1573434556162379982513}, //index = 103, scaled angle = 0.025146484375
      {0.9873014181578584347321, 0.1588581433338611681449}, //index = 104, scaled angle = 0.025390625
      {0.9870565713057510848216, 0.1603724572429280070818}, //index = 105, scaled angle = 0.025634765625
      {0.9868094018141855272575, 0.1618863937801115482351}, //index = 106, scaled angle = 0.02587890625
      {0.9865599102647755191953, 0.1633999493829729476868}, //index = 107, scaled angle = 0.026123046875
      {0.9863080972445986693842, 0.1649131204899696445665}, //index = 108, scaled angle = 0.0263671875
      {0.9860539633461954389659, 0.1664259035404638265021}, //index = 109, scaled angle = 0.026611328125
      {0.9857975091675674761404, 0.1679382949747308673150}, //index = 110, scaled angle = 0.02685546875
      {0.9855387353121761728758, 0.1694502912339676536924}, //index = 111, scaled angle = 0.027099609375
      {0.9852776423889413326407, 0.1709618887603009118603}, //index = 112, scaled angle = 0.02734375
      {0.9850142310122398381367, 0.1724730839967956452785}, //index = 113, scaled angle = 0.027587890625
      {0.9847485018019043190307, 0.1739838733874635168242}, //index = 114, scaled angle = 0.02783203125
      {0.9844804553832210425313, 0.1754942533772710921980}, //index = 115, scaled angle = 0.028076171875
      {0.9842100923869291362323, 0.1770042204121484163970}, //index = 116, scaled angle = 0.0283203125
      {0.9839374134492189227785, 0.1785137709389972016094}, //index = 117, scaled angle = 0.028564453125
      {0.9836624192117303655536, 0.1800229014056991816428}, //index = 118, scaled angle = 0.02880859375
      {0.9833851103215512923228, 0.1815316082611246328860}, //index = 119, scaled angle = 0.029052734375
      {0.9831054874312163960326, 0.1830398879551406177146}, //index = 120, scaled angle = 0.029296875
      {0.9828235511987053474314, 0.1845477369386192556533}, //index = 121, scaled angle = 0.029541015625
      {0.9825393022874413517798, 0.1860551516634462998478}, //index = 122, scaled angle = 0.02978515625
      {0.9822527413662894835156, 0.1875621285825292416938}, //index = 123, scaled angle = 0.030029296875
      {0.9819638691095553539867, 0.1890686641498058317978}, //index = 124, scaled angle = 0.0302734375
      {0.9816726861969832240717, 0.1905747548202524066507}, //index = 125, scaled angle = 0.030517578125
      {0.9813791933137546719124, 0.1920803970498920765220}, //index = 126, scaled angle = 0.03076171875
      {0.9810833911504867055342, 0.1935855872958032464215}, //index = 127, scaled angle = 0.031005859375
      {0.9807852804032305416015, 0.1950903220161278872613}, //index = 128, scaled angle = 0.03125
      {0.9804848617734693849712, 0.1965945976700798347725}, //index = 129, scaled angle = 0.031494140625
      {0.9801821359681174294920, 0.1980984107179531994447}, //index = 130, scaled angle = 0.03173828125
      {0.9798771036995177485807, 0.1996017576211305821765}, //index = 131, scaled angle = 0.031982421875
      {0.9795697656854406298876, 0.2011046348420915119704}, //index = 132, scaled angle = 0.0322265625
      {0.9792601226490821320070, 0.2026070388444207170942}, //index = 133, scaled angle = 0.032470703125
      {0.9789481753190623081196, 0.2041089660928164517539}, //index = 134, scaled angle = 0.03271484375
      {0.9786339244294232075916, 0.2056104130530988227665}, //index = 135, scaled angle = 0.032958984375
      {0.9783173707196277657516, 0.2071113761922181162323}, //index = 136, scaled angle = 0.033203125
      {0.9779985149345571393553, 0.2086118519782630686965}, //index = 137, scaled angle = 0.033447265625
      {0.9776773578245100404516, 0.2101118368804691938223}, //index = 138, scaled angle = 0.03369140625
      {0.9773539001452000718473, 0.2116113273692271368187}, //index = 139, scaled angle = 0.033935546875
      {0.9770281426577543948397, 0.2131103199160909178467}, //index = 140, scaled angle = 0.0341796875
      {0.9767000861287119528598, 0.2146088109937863142029}, //index = 141, scaled angle = 0.034423828125
      {0.9763697313300212510256, 0.2161067970762190482148}, //index = 142, scaled angle = 0.03466796875
      {0.9760370790390391348978, 0.2176042746384831694240}, //index = 143, scaled angle = 0.034912109375
      {0.9757021300385286810553, 0.2191012401568693257481}, //index = 144, scaled angle = 0.03515625
      {0.9753648851166570876714, 0.2205976901088730623979}, //index = 145, scaled angle = 0.035400390625
      {0.9750253450669942312246, 0.2220936209732030652830}, //index = 146, scaled angle = 0.03564453125
      {0.9746835106885107791186, 0.2235890292297895154405}, //index = 147, scaled angle = 0.035888671875
      {0.9743393827855759692369, 0.2250839113597923601962}, //index = 148, scaled angle = 0.0361328125
      {0.9739929621679559446079, 0.2265782638456095010593}, //index = 149, scaled angle = 0.036376953125
      {0.9736442496508120880705, 0.2280720831708852314179}, //index = 150, scaled angle = 0.03662109375
      {0.9732932460546983577387, 0.2295653658205183689223}, //index = 151, scaled angle = 0.036865234375
      {0.9729399522055602878012, 0.2310581082806706099131}, //index = 152, scaled angle = 0.037109375
      {0.9725843689347323239858, 0.2325503070387747173164}, //index = 153, scaled angle = 0.037353515625
      {0.9722264970789363802695, 0.2340419585835429028275}, //index = 154, scaled angle = 0.03759765625
      {0.9718663374802795074103, 0.2355330594049749870500}, //index = 155, scaled angle = 0.037841796875
      {0.9715038909862518945459, 0.2370236059943666706573}, //index = 156, scaled angle = 0.0380859375
      {0.9711391584497252038588, 0.2385135948443178888212}, //index = 157, scaled angle = 0.038330078125
      {0.9707721407289504611526, 0.2400030224487409435952}, //index = 158, scaled angle = 0.03857421875
      {0.9704028386875556133617, 0.2414918853028688028317}, //index = 159, scaled angle = 0.038818359375
      {0.9700312531945440852610, 0.2429801799032633435882}, //index = 160, scaled angle = 0.0390625
      {0.9696573851242925590199, 0.2444679027478236232884}, //index = 161, scaled angle = 0.039306640625
      {0.9692812353565486427343, 0.2459550503357940676175}, //index = 162, scaled angle = 0.03955078125
      {0.9689028047764289830468, 0.2474416191677727416831}, //index = 163, scaled angle = 0.039794921875
      {0.9685220942744174887906, 0.2489276057457195934219}, //index = 164, scaled angle = 0.0400390625
      {0.9681391047463625554315, 0.2504130065729646692496}, //index = 165, scaled angle = 0.040283203125
      {0.9677538370934756217778, 0.2518978181542163574669}, //index = 166, scaled angle = 0.04052734375
      {0.9673662922223287274903, 0.2533820369955695483988}, //index = 167, scaled angle = 0.040771484375
      {0.9669764710448522926356, 0.2548656596045139610673}, //index = 168, scaled angle = 0.041015625
      {0.9665843744783332303072, 0.2563486824899423033308}, //index = 169, scaled angle = 0.041259765625
      {0.9661900034454127261796, 0.2578311021621584320229}, //index = 170, scaled angle = 0.04150390625
      {0.9657933588740837960174, 0.2593129151328856241143}, //index = 171, scaled angle = 0.041748046875
      {0.9653944416976895093185, 0.2607941179152749033854}, //index = 172, scaled angle = 0.0419921875
      {0.9649932528549205468238, 0.2622747070239130340319}, //index = 173, scaled angle = 0.042236328125
      {0.9645897932898128690482, 0.2637546789748307918266}, //index = 174, scaled angle = 0.04248046875
      {0.9641840639517459399244, 0.2652340302855111797697}, //index = 175, scaled angle = 0.042724609375
      {0.9637760657954400622671, 0.2667127574748977547614}, //index = 176, scaled angle = 0.04296875
      {0.9633657997809542683498, 0.2681908570634025656965}, //index = 177, scaled angle = 0.043212890625
      {0.9629532668736840994583, 0.2696683255729144801371}, //index = 178, scaled angle = 0.04345703125
      {0.9625384680443593854449, 0.2711451595268073999634}, //index = 179, scaled angle = 0.043701171875
      {0.9621214042690418022374, 0.2726213554499483660010}, //index = 180, scaled angle = 0.0439453125
      {0.9617020765291227624161, 0.2740969098687057181607}, //index = 181, scaled angle = 0.044189453125
      {0.9612804858113208616999, 0.2755718193109575331334}, //index = 182, scaled angle = 0.04443359375
      {0.9608566331076797695232, 0.2770460803060992294178}, //index = 183, scaled angle = 0.044677734375
      {0.9604305194155660085897, 0.2785196893850524491043}, //index = 184, scaled angle = 0.044921875
      {0.9600021457376660682925, 0.2799926430802725518809}, //index = 185, scaled angle = 0.045166015625
      {0.9595715130819847393795, 0.2814649379257573302837}, //index = 186, scaled angle = 0.04541015625
      {0.9591386224618421163512, 0.2829365704570546702357}, //index = 187, scaled angle = 0.045654296875
      {0.9587034748958717100820, 0.2844075372112711552752}, //index = 188, scaled angle = 0.0458984375
      {0.9582660714080178943064, 0.2858778347270798936286}, //index = 189, scaled angle = 0.046142578125
      {0.9578264130275331300624, 0.2873474595447288448824}, //index = 190, scaled angle = 0.04638671875
      {0.9573845007889760783115, 0.2888164082060487580783}, //index = 191, scaled angle = 0.046630859375
      {0.9569403357322090464265, 0.2902846772544616649192}, //index = 192, scaled angle = 0.046875
      {0.9564939189023953236557, 0.2917522632349885958192}, //index = 193, scaled angle = 0.047119140625
      {0.9560452513499966276100, 0.2932191626942579620874}, //index = 194, scaled angle = 0.04736328125
      {0.9555943341307713279065, 0.2946853721805136050449}, //index = 195, scaled angle = 0.047607421875
      {0.9551411683057708934541, 0.2961508882436231226976}, //index = 196, scaled angle = 0.0478515625
      {0.9546857549413385601866, 0.2976157074350854747635}, //index = 197, scaled angle = 0.048095703125
      {0.9542280951091058893709, 0.2990798263080397534353}, //index = 198, scaled angle = 0.04833984375
      {0.9537681898859905471610, 0.3005432414172727328960}, //index = 199, scaled angle = 0.048583984375
      {0.9533060403541940841521, 0.3020059493192273070150}, //index = 200, scaled angle = 0.048828125
      {0.9528416476011989377781, 0.3034679465720105384641}, //index = 201, scaled angle = 0.049072265625
      {0.9523750127197661008438, 0.3049292297354016523236}, //index = 202, scaled angle = 0.04931640625
      {0.9519061368079325680114, 0.3063897953708601962219}, //index = 203, scaled angle = 0.049560546875
      {0.9514350209690085602432, 0.3078496400415341449630}, //index = 204, scaled angle = 0.0498046875
      {0.9509616663115753043556, 0.3093087603122679496437}, //index = 205, scaled angle = 0.050048828125
      {0.9504860739494819243944, 0.3107671527496107533040}, //index = 206, scaled angle = 0.05029296875
      {0.9500082450018432211891, 0.3122248139218241624882}, //index = 207, scaled angle = 0.050537109375
      {0.9495281805930368967950, 0.3136817403988906849399}, //index = 208, scaled angle = 0.05078125
      {0.9490458818527008899579, 0.3151379287525216121857}, //index = 209, scaled angle = 0.051025390625
      {0.9485613499157306005571, 0.3165933755561650686516}, //index = 210, scaled angle = 0.05126953125
      {0.9480745859222765581364, 0.3180480773850141162917}, //index = 211, scaled angle = 0.051513671875
      {0.9475855910177414243023, 0.3195020308160148592158}, //index = 212, scaled angle = 0.0517578125
      {0.9470943663527774392108, 0.3209552324278744372954}, //index = 213, scaled angle = 0.052001953125
      {0.9466009130832838680547, 0.3224076788010690197694}, //index = 214, scaled angle = 0.05224609375
      {0.9461052323704036703944, 0.3238593665178520764059}, //index = 215, scaled angle = 0.052490234375
      {0.9456073253805216127788, 0.3253102921622621490627}, //index = 216, scaled angle = 0.052734375
      {0.9451071932852608270537, 0.3267604523201309563163}, //index = 217, scaled angle = 0.052978515625
      {0.9446048372614805899161, 0.3282098435790917201338}, //index = 218, scaled angle = 0.05322265625
      {0.9441002584912729922451, 0.3296584625285866598787}, //index = 219, scaled angle = 0.053466796875
      {0.9435934581619606076330, 0.3311063057598755965394}, //index = 220, scaled angle = 0.0537109375
      {0.9430844374660937168287, 0.3325533698660433912231}, //index = 221, scaled angle = 0.053955078125
      {0.9425731976014471991121, 0.3339996514420085493846}, //index = 222, scaled angle = 0.05419921875
      {0.9420597397710176457153, 0.3354451470845307703428}, //index = 223, scaled angle = 0.054443359375
      {0.9415440651830210283535, 0.3368898533922192184420}, //index = 224, scaled angle = 0.0546875
      {0.9410261750508895906009, 0.3383337669655402946134}, //index = 225, scaled angle = 0.054931640625
      {0.9405060705932686282438, 0.3397768844068260185587}, //index = 226, scaled angle = 0.05517578125
      {0.9399837530340142688345, 0.3412192023202815227556}, //index = 227, scaled angle = 0.055419921875
      {0.9394592236021902520449, 0.3426607173119935456640}, //index = 228, scaled angle = 0.0556640625
      {0.9389324835320648210413, 0.3441014259899379812424}, //index = 229, scaled angle = 0.055908203125
      {0.9384035340631083910168, 0.3455413249639882056208}, //index = 230, scaled angle = 0.05615234375
      {0.9378723764399902185218, 0.3469804108459227931505}, //index = 231, scaled angle = 0.056396484375
      {0.9373390119125752928397, 0.3484186802494336765434}, //index = 232, scaled angle = 0.056640625
      {0.9368034417359218934962, 0.3498561297901340294558}, //index = 233, scaled angle = 0.056884765625
      {0.9362656671702785926570, 0.3512927560855662045824}, //index = 234, scaled angle = 0.05712890625
      {0.9357256894810807024143, 0.3527285557552098382850}, //index = 235, scaled angle = 0.057373046875
      {0.9351835099389479433185, 0.3541635254204894556196}, //index = 236, scaled angle = 0.0576171875
      {0.9346391298196811137089, 0.3555976617047829635432}, //index = 237, scaled angle = 0.057861328125
      {0.9340925504042593141563, 0.3570309612334291449187}, //index = 238, scaled angle = 0.05810546875
      {0.9335437729788365057715, 0.3584634206337356521210}, //index = 239, scaled angle = 0.058349609375
      {0.9329927988347392897595, 0.3598950365349872226872}, //index = 240, scaled angle = 0.05859375
      {0.9324396292684626885716, 0.3613258055684533398555}, //index = 241, scaled angle = 0.058837890625
      {0.9318842655816684805714, 0.3627557243673962816821}, //index = 242, scaled angle = 0.05908203125
      {0.9313267090811808701645, 0.3641847895670789481137}, //index = 243, scaled angle = 0.059326171875
      {0.9307669610789840453080, 0.3656129978047729101043}, //index = 244, scaled angle = 0.0595703125
      {0.9302050228922194019532, 0.3670403457197662366873}, //index = 245, scaled angle = 0.059814453125
      {0.9296408958431816582646, 0.3684668299533713775595}, //index = 246, scaled angle = 0.06005859375
      {0.9290745812593161900850, 0.3698924471489331566865}, //index = 247, scaled angle = 0.060302734375
      {0.9285060804732159223107, 0.3713171939518365993749}, //index = 248, scaled angle = 0.060546875
      {0.9279353948226182202674, 0.3727410670095148148562}, //index = 249, scaled angle = 0.060791015625
      {0.9273625256504014480186, 0.3741640629714570454034}, //index = 250, scaled angle = 0.06103515625
      {0.9267874743045821928078, 0.3755861784892162713589}, //index = 251, scaled angle = 0.061279296875
      {0.9262102421383117123455, 0.3770074102164172602514}, //index = 252, scaled angle = 0.0615234375
      {0.9256308305098731592508, 0.3784277548087646159125}, //index = 253, scaled angle = 0.061767578125
      {0.9250492407826780283386, 0.3798472089240502169716}, //index = 254, scaled angle = 0.06201171875
      {0.9244654743252630479944, 0.3812657692221613769945}, //index = 255, scaled angle = 0.062255859375
      {0.9238795325112871825723, 0.3826834323650887825785}, //index = 256, scaled angle = 0.0625
      {0.9232914167195280796818, 0.3841001950169340428687}, //index = 257, scaled angle = 0.062744140625
      {0.9227011283338789615627, 0.3855160538439178496972}, //index = 258, scaled angle = 0.06298828125
      {0.9221086687433455164609, 0.3869310055143875826111}, //index = 259, scaled angle = 0.063232421875
      {0.9215140393420423459148, 0.3883450466988253024780}, //index = 260, scaled angle = 0.0634765625
      {0.9209172415291898561307, 0.3897581740698554675362}, //index = 261, scaled angle = 0.063720703125
      {0.9203182767091110383362, 0.3911703843022528714890}, //index = 262, scaled angle = 0.06396484375
      {0.9197171462912278050439, 0.3925816740729504705776}, //index = 263, scaled angle = 0.064208984375
      {0.9191138516900582144942, 0.3939920400610470996305}, //index = 264, scaled angle = 0.064453125
      {0.9185083943252126958967, 0.3954014789478152991364}, //index = 265, scaled angle = 0.064697265625
      {0.9179007756213909408061, 0.3968099874167093088495}, //index = 266, scaled angle = 0.06494140625
      {0.9172909970083783504080, 0.3982175621533725617951}, //index = 267, scaled angle = 0.065185546875
      {0.9166790599210431489396, 0.3996241998456457888977}, //index = 268, scaled angle = 0.0654296875
      {0.9160649657993321648419, 0.4010298971835746240089}, //index = 269, scaled angle = 0.065673828125
      {0.9154487160882682772467, 0.4024346508594173754680}, //index = 270, scaled angle = 0.06591796875
      {0.9148303122379466412184, 0.4038384575676530752197}, //index = 271, scaled angle = 0.066162109375
      {0.9142097557035311350404, 0.4052413140049888062855}, //index = 272, scaled angle = 0.06640625
      {0.9135870479452512515905, 0.4066432168703679739252}, //index = 273, scaled angle = 0.066650390625
      {0.9129621904283986566497, 0.4080441628649776331095}, //index = 274, scaled angle = 0.06689453125
      {0.9123351846233231920991, 0.4094441486922565376361}, //index = 275, scaled angle = 0.067138671875
      {0.9117060320054303224069, 0.4108431710579028561803}, //index = 276, scaled angle = 0.0673828125
      {0.9110747340551768047590, 0.4122412266698818328337}, //index = 277, scaled angle = 0.067626953125
      {0.9104412922580676914563, 0.4136383122384334476429}, //index = 278, scaled angle = 0.06787109375
      {0.9098057081046527772017, 0.4150344244760805212380}, //index = 279, scaled angle = 0.068115234375
      {0.9091679830905228243410, 0.4164295600976360978152}, //index = 280, scaled angle = 0.068359375
      {0.9085281187163066762835, 0.4178237158202112166983}, //index = 281, scaled angle = 0.068603515625
      {0.9078861164876667055879, 0.4192168883632228504332}, //index = 282, scaled angle = 0.06884765625
      {0.9072419779152963714708, 0.4206090744484013987936}, //index = 283, scaled angle = 0.069091796875
      {0.9065957045149158899378, 0.4220002707997985713639}, //index = 284, scaled angle = 0.0693359375
      {0.9059472978072690141360, 0.4233904741437949370564}, //index = 285, scaled angle = 0.069580078125
      {0.9052967593181192595964, 0.4247796812091076956719}, //index = 286, scaled angle = 0.06982421875
      {0.9046440905782466845864, 0.4261678887267985049725}, //index = 287, scaled angle = 0.070068359375
      {0.9039892931234438933075, 0.4275550934302809746868}, //index = 288, scaled angle = 0.0703125
      {0.9033323684945123721590, 0.4289412920553283825598}, //index = 289, scaled angle = 0.070556640625
      {0.9026733182372593811138, 0.4303264813400815014255}, //index = 290, scaled angle = 0.07080078125
      {0.9020121439024937348705, 0.4317106580250561487233}, //index = 291, scaled angle = 0.071044921875
      {0.9013488470460225832070, 0.4330938188531508470369}, //index = 292, scaled angle = 0.0712890625
      {0.9006834292286474141775, 0.4344759605696545401443}, //index = 293, scaled angle = 0.071533203125
      {0.9000158920161608344657, 0.4358570799222543645790}, //index = 294, scaled angle = 0.07177734375
      {0.8993462369793421284925, 0.4372371736610429771019}, //index = 295, scaled angle = 0.072021484375
      {0.8986744656939543718366, 0.4386162385385264927962}, //index = 296, scaled angle = 0.072265625
      {0.8980005797407404344312, 0.4399942713096320900945}, //index = 297, scaled angle = 0.072509765625
      {0.8973245807054188727392, 0.4413712687317155602962}, //index = 298, scaled angle = 0.07275390625
      {0.8966464701786808211281, 0.4427472275645688570833}, //index = 299, scaled angle = 0.072998046875
      {0.8959662497561857730233, 0.4441221445704280901268}, //index = 300, scaled angle = 0.0732421875
      {0.8952839210385581392160, 0.4454960165139805750023}, //index = 301, scaled angle = 0.073486328125
      {0.8945994856313832510608, 0.4468688401623730488410}, //index = 302, scaled angle = 0.07373046875
      {0.8939129451452038077619, 0.4482406122852187202454}, //index = 303, scaled angle = 0.073974609375
      {0.8932243011955158795701, 0.4496113296546054294289}, //index = 304, scaled angle = 0.07421875
      {0.8925335554027652440467, 0.4509809890451026981317}, //index = 305, scaled angle = 0.074462890625
      {0.8918407093923432782390, 0.4523495872337696677157}, //index = 306, scaled angle = 0.07470703125
      {0.8911457647945838500547, 0.4537171210001627041919}, //index = 307, scaled angle = 0.074951171875
      {0.8904487232447585443040, 0.4550835871263426146704}, //index = 308, scaled angle = 0.0751953125
      {0.8897495863830734430522, 0.4564489823968827519884}, //index = 309, scaled angle = 0.075439453125
      {0.8890483558546651288168, 0.4578133035988760091151}, //index = 310, scaled angle = 0.07568359375
      {0.8883450333095969098096, 0.4591765475219429237796}, //index = 311, scaled angle = 0.075927734375
      {0.8876396204028546010889, 0.4605387109582388394102}, //index = 312, scaled angle = 0.076171875
      {0.8869321187943428608236, 0.4618997907024615101612}, //index = 313, scaled angle = 0.076416015625
      {0.8862225301488813045125, 0.4632597835518589834969}, //index = 314, scaled angle = 0.07666015625
      {0.8855108561362006192041, 0.4646186863062365945964}, //index = 315, scaled angle = 0.076904296875
      {0.8847970984309384556710, 0.4659764957679649599598}, //index = 316, scaled angle = 0.0771484375
      {0.8840812587126356536515, 0.4673332087419871938572}, //index = 317, scaled angle = 0.077392578125
      {0.8833633386657322450475, 0.4686888220358266798904}, //index = 318, scaled angle = 0.07763671875
      {0.8826433399795634571205, 0.4700433324595943984647}, //index = 319, scaled angle = 0.077880859375
      {0.8819212643483557156898, 0.4713967368259964207944}, //index = 320, scaled angle = 0.078125
      {0.8811971134712227593511, 0.4727490319503415694413}, //index = 321, scaled angle = 0.078369140625
      {0.8804708890521614206293, 0.4741002146505487457873}, //index = 322, scaled angle = 0.07861328125
      {0.8797425928000480732649, 0.4754502817471546460837}, //index = 323, scaled angle = 0.078857421875
      {0.8790122264286341913220, 0.4767992300633208668792}, //index = 324, scaled angle = 0.0791015625
      {0.8782797916565422413626, 0.4781470564248417876030}, //index = 325, scaled angle = 0.079345703125
      {0.8775452902072619076890, 0.4794937576601517870145}, //index = 326, scaled angle = 0.07958984375
      {0.8768087238091463175849, 0.4808393306003327927201}, //index = 327, scaled angle = 0.079833984375
      {0.8760700941954072673568, 0.4821837720791216086447}, //index = 328, scaled angle = 0.080078125
      {0.8753294031041114475755, 0.4835270789329176310822}, //index = 329, scaled angle = 0.080322265625
      {0.8745866522781766683181, 0.4848692480007900651451}, //index = 330, scaled angle = 0.08056640625
      {0.8738418434653674182755, 0.4862102761244854187694}, //index = 331, scaled angle = 0.080810546875
      {0.8730949784182906459051, 0.4875501601484349967208}, //index = 332, scaled angle = 0.0810546875
      {0.8723460588943919846727, 0.4888888969197622835772}, //index = 333, scaled angle = 0.081298828125
      {0.8715950866559515342047, 0.4902264832882903267119}, //index = 334, scaled angle = 0.08154296875
      {0.8708420634700794193961, 0.4915629161065491192772}, //index = 335, scaled angle = 0.081787109375
      {0.8700869911087119046300, 0.4928981922297832607427}, //index = 336, scaled angle = 0.08203125
      {0.8693298713486071749301, 0.4942323085159590068116}, //index = 337, scaled angle = 0.082275390625
      {0.8685707059713412281354, 0.4955652618257718744488}, //index = 338, scaled angle = 0.08251953125
      {0.8678094967633036560528, 0.4968970490226539138412}, //index = 339, scaled angle = 0.082763671875
      {0.8670462455156929815203, 0.4982276669727812579147}, //index = 340, scaled angle = 0.0830078125
      {0.8662809540245133277381, 0.4995571125450813387836}, //index = 341, scaled angle = 0.083251953125
      {0.8655136240905694222647, 0.5008853826112402707338}, //index = 342, scaled angle = 0.08349609375
      {0.8647442575194626002144, 0.5022124740457103442282}, //index = 343, scaled angle = 0.083740234375
      {0.8639728561215870294987, 0.5035383837257171313340}, //index = 344, scaled angle = 0.083984375
      {0.8631994217121243817559, 0.5048631085312671462617}, //index = 345, scaled angle = 0.084228515625
      {0.8624239561110407237265, 0.5061866453451550063036}, //index = 346, scaled angle = 0.08447265625
      {0.8616464611430815212501, 0.5075089910529705372610}, //index = 347, scaled angle = 0.084716796875
      {0.8608669386377674204169, 0.5088301425431067670502}, //index = 348, scaled angle = 0.0849609375
      {0.8600853904293902507661, 0.5101500967067665870402}, //index = 349, scaled angle = 0.085205078125
      {0.8593018183570084733702, 0.5114688504379703015701}, //index = 350, scaled angle = 0.08544921875
      {0.8585162242644428509664, 0.5127864006335629554201}, //index = 351, scaled angle = 0.085693359375
      {0.8577286100002721180857, 0.5141027441932216612841}, //index = 352, scaled angle = 0.0859375
      {0.8569389774178287622064, 0.5154178780194629272415}, //index = 353, scaled angle = 0.086181640625
      {0.8561473283751944718389, 0.5167317990176498732069}, //index = 354, scaled angle = 0.08642578125
      {0.8553536647351959176788, 0.5180445040959994473795}, //index = 355, scaled angle = 0.086669921875
      {0.8545579883654004227367, 0.5193559901655896426931}, //index = 356, scaled angle = 0.0869140625
      {0.8537603011381112994016, 0.5206662541403672683771}, //index = 357, scaled angle = 0.087158203125
      {0.8529606049303635195713, 0.5219752929371545002724}, //index = 358, scaled angle = 0.08740234375
      {0.8521589016239197178493, 0.5232831034756566523924}, //index = 359, scaled angle = 0.087646484375
      {0.8513551931052649734966, 0.5245896826784691713286}, //index = 360, scaled angle = 0.087890625
      {0.8505494812656032577181, 0.5258950274710849637216}, //index = 361, scaled angle = 0.088134765625
      {0.8497417680008522156143, 0.5271991347819017237342}, //index = 362, scaled angle = 0.08837890625
      {0.8489320552116393914233, 0.5285020015422288164331}, //index = 363, scaled angle = 0.088623046875
      {0.8481203448032970104720, 0.5298036246862951603731}, //index = 364, scaled angle = 0.0888671875
      {0.8473066386858580933961, 0.5311040011512554448458}, //index = 365, scaled angle = 0.089111328125
      {0.8464909387740517932031, 0.5324031278771984565523}, //index = 366, scaled angle = 0.08935546875
      {0.8456732469872987323356, 0.5337010018071535188966}, //index = 367, scaled angle = 0.089599609375
      {0.8448535652497066728017, 0.5349976198870978194577}, //index = 368, scaled angle = 0.08984375
      {0.8440318954900659642604, 0.5362929790659638484840}, //index = 369, scaled angle = 0.090087890625
      {0.8432082396418449921072, 0.5375870762956461712534}, //index = 370, scaled angle = 0.09033203125
      {0.8423825996431854035151, 0.5388799085310091996348}, //index = 371, scaled angle = 0.090576171875
      {0.8415549774368978885875, 0.5401714727298936313815}, //index = 372, scaled angle = 0.0908203125
      {0.8407253749704575174206, 0.5414617658531243327147}, //index = 373, scaled angle = 0.091064453125
      {0.8398937941959989661456, 0.5427507848645167776169}, //index = 374, scaled angle = 0.09130859375
      {0.8390602370703120760353, 0.5440385267308848193935}, //index = 375, scaled angle = 0.091552734375
      {0.8382247055548374126133, 0.5453249884220473520102}, //index = 376, scaled angle = 0.091796875
      {0.8373872016156612696491, 0.5466101669108358596105}, //index = 377, scaled angle = 0.092041015625
      {0.8365477272235113392895, 0.5478940591731011888754}, //index = 378, scaled angle = 0.09228515625
      {0.8357062843537518270765, 0.5491766621877207654734}, //index = 379, scaled angle = 0.092529296875
      {0.8348628749863793441222, 0.5504579729366059215323}, //index = 380, scaled angle = 0.0927734375
      {0.8340175011060173559940, 0.5517379884047085569776}, //index = 381, scaled angle = 0.093017578125
      {0.8331701647019124079563, 0.5530167055800286890488}, //index = 382, scaled angle = 0.09326171875
      {0.8323208677679287958995, 0.5542941214536213356823}, //index = 383, scaled angle = 0.093505859375
      {0.8314696123025443474930, 0.5555702330196035099164}, //index = 384, scaled angle = 0.09375
      {0.8306164003088454261814, 0.5568450372751614363409}, //index = 385, scaled angle = 0.093994140625
      {0.8297612337945221572255, 0.5581185312205574344802}, //index = 386, scaled angle = 0.09423828125
      {0.8289041147718639868103, 0.5593907118591374683092}, //index = 387, scaled angle = 0.094482421875
      {0.8280450452577547970634, 0.5606615761973374745253}, //index = 388, scaled angle = 0.0947265625
      {0.8271840272736681320964, 0.5619311212446909120644}, //index = 389, scaled angle = 0.094970703125
      {0.8263210628456624240457, 0.5631993440138356454838}, //index = 390, scaled angle = 0.09521484375
      {0.8254561540043764411578, 0.5644662415205210503899}, //index = 391, scaled angle = 0.095458984375
      {0.8245893027850241807641, 0.5657318107836147857981}, //index = 392, scaled angle = 0.095703125
      {0.8237205112273902063436, 0.5669960488251102326274}, //index = 393, scaled angle = 0.095947265625
      {0.8228497813758252066307, 0.5682589526701332660608}, //index = 394, scaled angle = 0.09619140625
      {0.8219771152792403334786, 0.5695205193469489168834}, //index = 395, scaled angle = 0.096435546875
      {0.8211025149911034271000, 0.5707807458869690320213}, //index = 396, scaled angle = 0.0966796875
      {0.8202259825694334649526, 0.5720396293247588248576}, //index = 397, scaled angle = 0.096923828125
      {0.8193475200767956767578, 0.5732971666980440916817}, //index = 398, scaled angle = 0.09716796875
      {0.8184671295802973256528, 0.5745533550477176509830}, //index = 399, scaled angle = 0.097412109375
      {0.8175848131515823791204, 0.5758081914178472260346}, //index = 400, scaled angle = 0.09765625
      {0.8167005728668264019632, 0.5770616728556814400974}, //index = 401, scaled angle = 0.097900390625
      {0.8158144108067323374556, 0.5783137964116575879814}, //index = 402, scaled angle = 0.09814453125
      {0.8149263290565251782738, 0.5795645591394077422720}, //index = 403, scaled angle = 0.098388671875
      {0.8140363297059468594696, 0.5808139580957666359140}, //index = 404, scaled angle = 0.0986328125
      {0.8131444148492520396232, 0.5820619903407776574156}, //index = 405, scaled angle = 0.098876953125
      {0.8122505865852023276830, 0.5833086529377004003649}, //index = 406, scaled angle = 0.09912109375
      {0.8113548470170621751407, 0.5845539429530174357907}, //index = 407, scaled angle = 0.099365234375
      {0.8104571982525932138941, 0.5857978574564410845227}, //index = 408, scaled angle = 0.099609375
      {0.8095576424040495933099, 0.5870403935209203005741}, //index = 409, scaled angle = 0.099853515625
      {0.8086561815881733172873, 0.5882815482226475545247}, //index = 410, scaled angle = 0.10009765625
      {0.8077528179261886931428, 0.5895213186410662720149}, //index = 411, scaled angle = 0.100341796875
      {0.8068475535437975576514, 0.5907597018588766069058}, //index = 412, scaled angle = 0.1005859375
      {0.8059403905711745030871, 0.5919966949620433238621}, //index = 413, scaled angle = 0.100830078125
      {0.8050313311429617701975, 0.5932322950398022376461}, //index = 414, scaled angle = 0.10107421875
      {0.8041203773982639191331, 0.5944664991846669854780}, //index = 415, scaled angle = 0.101318359375
      {0.8032075314806430554881, 0.5956993044924359104186}, //index = 416, scaled angle = 0.1015625
      {0.8022927955381138342972, 0.5969307080621990557745}, //index = 417, scaled angle = 0.101806640625
      {0.8013761717231382419868, 0.5981607069963449374583}, //index = 418, scaled angle = 0.10205078125
      {0.8004576621926208224167, 0.5993892984005672053271}, //index = 419, scaled angle = 0.102294921875
      {0.7995372691079030147421, 0.6006164793838716375873}, //index = 420, scaled angle = 0.1025390625
      {0.7986149946347588235440, 0.6018422470585828021328}, //index = 421, scaled angle = 0.102783203125
      {0.7976908409433890456697, 0.6030665985403509399276}, //index = 422, scaled angle = 0.10302734375
      {0.7967648102084166072956, 0.6042895309481588483891}, //index = 423, scaled angle = 0.103271484375
      {0.7958369046088813458795, 0.6055110414043283206809}, //index = 424, scaled angle = 0.103515625
      {0.7949071263282347921120, 0.6067311270345273621629}, //index = 425, scaled angle = 0.103759765625
      {0.7939754775543349518685, 0.6079497849677765186627}, //index = 426, scaled angle = 0.10400390625
      {0.7930419604794414212279, 0.6091670123364560929247}, //index = 427, scaled angle = 0.104248046875
      {0.7921065773002100574018, 0.6103828062763123618595}, //index = 428, scaled angle = 0.1044921875
      {0.7911693302176878717091, 0.6115971639264649040157}, //index = 429, scaled angle = 0.104736328125
      {0.7902302214373077005050, 0.6128100824294127058067}, //index = 430, scaled angle = 0.10498046875
      {0.7892892531688833201997, 0.6140215589310414889823}, //index = 431, scaled angle = 0.105224609375
      {0.7883464276266037851215, 0.6152315905806299278780}, //index = 432, scaled angle = 0.10546875
      {0.7874017470290288756019, 0.6164401745308567548420}, //index = 433, scaled angle = 0.105712890625
      {0.7864552135990832137935, 0.6176473079378070885070}, //index = 434, scaled angle = 0.10595703125
      {0.7855068295640513786893, 0.6188529879609795392170}, //index = 435, scaled angle = 0.106201171875
      {0.7845565971555726880737, 0.6200572117632924262765}, //index = 436, scaled angle = 0.1064453125
      {0.7836045186096356474081, 0.6212599765110908833776}, //index = 437, scaled angle = 0.106689453125
      {0.7826505961665730648491, 0.6224612793741532978942}, //index = 438, scaled angle = 0.10693359375
      {0.7816948320710567221781, 0.6236611175256979722192}, //index = 439, scaled angle = 0.107177734375
      {0.7807372285720917126639, 0.6248594881423897851036}, //index = 440, scaled angle = 0.107421875
      {0.7797777879230117781262, 0.6260563884043469640162}, //index = 441, scaled angle = 0.107666015625
      {0.7788165123814732027085, 0.6272518154951475244374}, //index = 442, scaled angle = 0.10791015625
      {0.7778534042094502609643, 0.6284457666018361532423}, //index = 443, scaled angle = 0.108154296875
      {0.7768884656732295557191, 0.6296382389149305369713}, //index = 444, scaled angle = 0.1083984375
      {0.7759216990434046890002, 0.6308292296284281341912}, //index = 445, scaled angle = 0.108642578125
      {0.7749531065948709329660, 0.6320187359398126147880}, //index = 446, scaled angle = 0.10888671875
      {0.7739826906068197898136, 0.6332067550500608543729}, //index = 447, scaled angle = 0.109130859375
      {0.7730104533627339957746, 0.6343932841636491515303}, //index = 448, scaled angle = 0.109375
      {0.7720363971503814148889, 0.6355783204885598891565}, //index = 449, scaled angle = 0.109619140625
      {0.7710605242618107091346, 0.6367618612362879737532}, //index = 450, scaled angle = 0.10986328125
      {0.7700828369933447881124, 0.6379439036218478298323}, //index = 451, scaled angle = 0.110107421875
      {0.7691033376455764791757, 0.6391244448637795061430}, //index = 452, scaled angle = 0.1103515625
      {0.7681220285233621991594, 0.6403034821841555590538}, //index = 453, scaled angle = 0.110595703125
      {0.7671389119358171804208, 0.6414810128085870477577}, //index = 454, scaled angle = 0.11083984375
      {0.7661539901963095866577, 0.6426570339662307507211}, //index = 455, scaled angle = 0.111083984375
      {0.7651672656224556279270, 0.6438315428897953829335}, //index = 456, scaled angle = 0.111328125
      {0.7641787405361133433956, 0.6450045368155479241778}, //index = 457, scaled angle = 0.111572265625
      {0.7631884172633778273820, 0.6461760129833203913918}, //index = 458, scaled angle = 0.11181640625
      {0.7621962981345754561957, 0.6473459686365161669386}, //index = 459, scaled angle = 0.112060546875
      {0.7612023854842583370228, 0.6485144010221165489227}, //index = 460, scaled angle = 0.1123046875
      {0.7602066816511988678329, 0.6496813073906873015062}, //index = 461, scaled angle = 0.112548828125
      {0.7592091889783845193307, 0.6508466849963850942018}, //index = 462, scaled angle = 0.11279296875
      {0.7582099098130117287297, 0.6520105310969637191221}, //index = 463, scaled angle = 0.113037109375
      {0.7572088465064809037486, 0.6531728429537809743621}, //index = 464, scaled angle = 0.11328125
      {0.7562060014143908714956, 0.6543336178318047702263}, //index = 465, scaled angle = 0.113525390625
      {0.7552013768965327722427, 0.6554928529996196795437}, //index = 466, scaled angle = 0.11376953125
      {0.7541949753168853964880, 0.6566505457294333769624}, //index = 467, scaled angle = 0.114013671875
      {0.7531867990436087456629, 0.6578066932970829672200}, //index = 468, scaled angle = 0.1142578125
      {0.7521768504490389251060, 0.6589612929820416464821}, //index = 469, scaled angle = 0.114501953125
      {0.7511651319096825929478, 0.6601143420674249195912}, //index = 470, scaled angle = 0.11474609375
      {0.7501516458062111869509, 0.6612658378399965952710}, //index = 471, scaled angle = 0.114990234375
      {0.7491363945234553733954, 0.6624157775901762246207}, //index = 472, scaled angle = 0.115234375
      {0.7481193804503996069855, 0.6635641586120443191632}, //index = 473, scaled angle = 0.115478515625
      {0.7471006059801761356454, 0.6647109782033493452502}, //index = 474, scaled angle = 0.11572265625
      {0.7460800735100596714489, 0.6658562336655142743780}, //index = 475, scaled angle = 0.115966796875
      {0.7450577854414618395040, 0.6669999223036421343025}, //index = 476, scaled angle = 0.1162109375
      {0.7440337441799250717267, 0.6681420414265231144668}, //index = 477, scaled angle = 0.116455078125
      {0.7430079521351174998145, 0.6692825883466406722277}, //index = 478, scaled angle = 0.11669921875
      {0.7419804117208267379979, 0.6704215603801777501047}, //index = 479, scaled angle = 0.116943359375
      {0.7409511253549547760144, 0.6715589548470231040511}, //index = 480, scaled angle = 0.1171875
      {0.7399200954595118728818, 0.6726947690707776317254}, //index = 481, scaled angle = 0.117431640625
      {0.7388873244606107837384, 0.6738290003787608117847}, //index = 482, scaled angle = 0.11767578125
      {0.7378528147884616528174, 0.6749616461020168101115}, //index = 483, scaled angle = 0.117919921875
      {0.7368165688773654631305, 0.6760927035753208080848}, //index = 484, scaled angle = 0.1181640625
      {0.7357785891657090404649, 0.6772221701371853308515}, //index = 485, scaled angle = 0.118408203125
      {0.7347388780959589471564, 0.6783500431298663535529}, //index = 486, scaled angle = 0.11865234375
      {0.7336974381146557089295, 0.6794763198993699626627}, //index = 487, scaled angle = 0.118896484375
      {0.7326542716724082637825, 0.6806009977954580181247}, //index = 488, scaled angle = 0.119140625
      {0.7316093812238878557608, 0.6817240741716548146911}, //index = 489, scaled angle = 0.119384765625
      {0.7305627692278229279310, 0.6828455463852530771263}, //index = 490, scaled angle = 0.11962890625
      {0.7295144381469922389982, 0.6839654117973205105230}, //index = 491, scaled angle = 0.119873046875
      {0.7284643904482204224138, 0.6850836677727054624398}, //index = 492, scaled angle = 0.1201171875
      {0.7274126286023709919704, 0.6862003116800436952616}, //index = 493, scaled angle = 0.120361328125
      {0.7263591550843411237537, 0.6873153408917642703813}, //index = 494, scaled angle = 0.12060546875
      {0.7253039723730558829828, 0.6884287527840956544267}, //index = 495, scaled angle = 0.120849609375
      {0.7242470829514620067613, 0.6895405447370721585543}, //index = 496, scaled angle = 0.12109375
      {0.7231884893065224639841, 0.6906507141345398226306}, //index = 497, scaled angle = 0.121337890625
      {0.7221281939292103491113, 0.6917592583641629655489}, //index = 498, scaled angle = 0.12158203125
      {0.7210661993145029979857, 0.6928661748174299583880}, //index = 499, scaled angle = 0.121826171875
      {0.7200025079613765477404, 0.6939714608896593306397}, //index = 500, scaled angle = 0.1220703125
      {0.7189371223727992754604, 0.6950751139800062095020}, //index = 501, scaled angle = 0.122314453125
      {0.7178700450557264911566, 0.6961771314914683150832}, //index = 502, scaled angle = 0.12255859375
      {0.7168012785210943205172, 0.6972775108308919556066}, //index = 503, scaled angle = 0.122802734375
      {0.7157308252838133766360, 0.6983762494089782446594}, //index = 504, scaled angle = 0.123046875
      {0.7146586878627637640093, 0.6994733446402892074190}, //index = 505, scaled angle = 0.123291015625
      {0.7135848687807881951528, 0.7005687939432538868800}, //index = 506, scaled angle = 0.12353515625
      {0.7125093705646868835757, 0.7016625947401740059917}, //index = 507, scaled angle = 0.123779296875
      {0.7114321957452109934650, 0.7027547444572308510402}, //index = 508, scaled angle = 0.1240234375
      {0.7103533468570568665257, 0.7038452405244904896975}, //index = 509, scaled angle = 0.124267578125
      {0.7092728264388601377988, 0.7049340803759104323589}, //index = 510, scaled angle = 0.12451171875
      {0.7081906370331897404569, 0.7060212614493454053033}  //index = 511, scaled angle = 0.124755859375
    };  //End of code generated by ac_sincos_lut_lutgen.cpp



    typedef ac_int<AC_MAX(T_in::width-T_in::i_width-3, 1), false> lutindextype1;
    // Extracting (MSB-3:LSB) bits of scaled input to determine the lookup table index
    lutindextype1 lut_index1 = posinput.template slc<AC_MAX(T_in::width-T_in::i_width-3, 1)>(0);  // Extracting the lookup table index

    #pragma hls_waive CNS
    if (T_in::width-T_in::i_width>=4 && T_in::width-T_in::i_width<=12) {
      lut_index.set_slc(12- (T_in::width - T_in::i_width), lut_index1);                           // stride
    }
    //Approximation for the scaled inputs whose number of bits are greater than 12
    else if (T_in::width-T_in::i_width>12) {
      // Lookup table index for the scaled inputs whose number of bits are greater than 12
      lut_index = lut_index1/(1<<(AC_MAX(T_in::width-T_in::i_width-12, 0)));
      if ((lut_index1 % (1<<(AC_MAX(T_in::width-T_in::i_width-12,0)))) > (1<<(AC_MAX(T_in::width-T_in::i_width-13,0)))) {
        lut_index = lut_index + 1;
      }
      typedef ac_fixed<AC_MAX((AC_MAX(T_in::width-T_in::i_width-3, 1) + T_in::width-T_in::i_width-12), 1), AC_MAX(T_in::width-T_in::i_width-3, 1), false> datatype;
      datatype x = (datatype)lut_index1;
      x = x >> AC_MAX(T_in::width-T_in::i_width-12, 0);
      if (x > 511.5)
      { lut_index = 511; }
      if (lut_index1 <= 1<<(AC_MAX(T_in::width-T_in::i_width-13,0)) && lut_index1 != 0)
      { lut_index = 1; }
    }

    #pragma hls_waive CNS
    if (T_in::width-T_in::i_width>=3) {
      // Getting the octant 0-7 by extracting the first 3 bits from MSB side of scaled input where
      //   octant 0 corresponds to [0-PI/4),
      //   octant 1 corresponds to [PI/4-2PI/4),
      //   octant 2 corresponds to [2PI/4-3PI/4) and so on
      octanttype octant = posinput.template slc<3>(T_in::width-T_in::i_width-3);
      lut_index = (octant[0] == 1)?(lutindextype)(512-lut_index):(lutindextype)(lut_index);
      // imaginary part is sine
      outputtemp.i() = ((octant==0) | (octant==3)) ? (T_out) sincos[lut_index].i():
                       ((octant==2) | (octant==1)) ? (T_out) sincos[lut_index].r():
                       ((octant==7) | (octant==4)) ? (T_out)-sincos[lut_index].i():
                       (T_out)-sincos[lut_index].r();
      // real part is cosine
      outputtemp.r() = ((octant==6) | (octant==1)) ? (T_out) sincos[lut_index].i():
                       ((octant==3) | (octant==4)) ? (T_out)-sincos[lut_index].r():
                       ((octant==2) | (octant==5)) ? (T_out)-sincos[lut_index].i():
                       (T_out) sincos[lut_index].r();
      // Below two are the cases when the output corresponds to + or - (0 or 1) for which there is no entry in the lookup table
      output.i() = ((posinput==0.125) | (posinput==0.375)) ?  0.7071067811865475244008:
                   ((posinput==0.625) | (posinput==0.875)) ? -0.7071067811865475244008:
                   outputtemp.i();
      output.r() = ((posinput==0.125) | (posinput==0.875)) ?  0.7071067811865475244008:
                   ((posinput==0.375) | (posinput==0.625)) ? -0.7071067811865475244008:
                   outputtemp.r();
    }

    #pragma hls_waive CNS
    if (T_in::width-T_in::i_width <= 2) {
      output.i() = (posinput==0   ) ? (T_out) 0:
                   (posinput==0.25) ? (T_out) 1:
                   (posinput==0.5 ) ? (T_out) 0:
                   (posinput==0.75) ? (T_out)-1:
                   outputtemp.i();
      output.r() = (posinput==0   ) ? (T_out) 1:
                   (posinput==0.25) ? (T_out) 0:
                   (posinput==0.5 ) ? (T_out)-1:
                   (posinput==0.75) ? (T_out) 0:
                   outputtemp.r();
    }

    #if !defined(__SYNTHESIS__) && defined(AC_SINCOS_LUT_H_DEBUG)
    std::cout << "FILE : " << __FILE__ << ", LINE : " << __LINE__ << std::endl;
    std::cout << "============AC_FIXED SINCOS======================" << std::endl;
    std::cout << "positive input is   = " << posinput << std::endl;
    std::cout << "lut index is   = " << lut_index << std::endl;
    std::cout << "sin value is    = " << output.i() << std::endl;
    std::cout << "cos value is    = " << output.r() << std::endl;
    std::cout << "=================================================" << std::endl;
    #endif
  }

//============================================================================
// Version that allows returning of values.
  template<class T_out, class T_in>
  T_out ac_sincos_lut(
    const T_in &input
  )
  {
    T_out output;
    ac_sincos_lut(input, output);
    return output;
  }
} // namespace ac_math

#endif

